package in.muton.edushare.components.autocomplete;

import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.JavascriptPackageResource;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;

public class EdushareTextField extends TextField<String> {
	private static final long serialVersionUID = -6374478807019457294L;

	public EdushareTextField(String id, IModel<String> model) {
		super(id, model);
		add(JavascriptPackageResource.getHeaderContribution(
				EdushareTextField.class, "EdushareAutoComplete.js"));
		add(new SimpleAttributeModifier("class", "wicketAutoCompleteComponent"));
		add(behaviour = new EdushareAutoCompleteBehaviour(this));
	}

	@Override
	protected void onComponentTag(ComponentTag tag) {
		super.onComponentTag(tag);
		tag.put("url", behaviour.getCallbackUrl());
	}


	private EdushareAutoCompleteBehaviour behaviour = null;
}
